package com.woniu.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.apartment.domain.University;
import com.woniu.apartment.service.IUniversityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大学列Controller
 * 
 * @author yy
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/apartment/tbuniversity")
@Api("大学列管理")
public class UniversityController extends BaseController
{
    @Autowired
    private IUniversityService universityService;

    /**
     * 查询大学列列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbuniversity:list')")
    @GetMapping("/list")
    @ApiOperation("大学列分页查询")
    public TableDataInfo list(University university)
    {
        startPage();
        List<University> list = universityService.selectUniversityList(university);
        return getDataTable(list);
    }

    /**
     * 导出大学列列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbuniversity:export')")
    @Log(title = "大学列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("大学列导出")
    public void export(HttpServletResponse response, University university)
    {
        List<University> list = universityService.selectUniversityList(university);
        ExcelUtil<University> util = new ExcelUtil<University>(University.class);
        util.exportExcel(response, list, "大学列数据");
    }

    /**
     * 获取大学列详细信息
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbuniversity:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询大学列")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(universityService.selectUniversityById(id));
    }

    /**
     * 新增大学列
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbuniversity:add')")
    @Log(title = "大学列", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加大学列")
    public AjaxResult add(@RequestBody University university)
    {
        return toAjax(universityService.insertUniversity(university));
    }

    /**
     * 修改大学列
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbuniversity:edit')")
    @Log(title = "大学列", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新大学列")
    public AjaxResult edit(@RequestBody University university)
    {
        return toAjax(universityService.updateUniversity(university));
    }

    /**
     * 删除大学列
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbuniversity:remove')")
    @Log(title = "大学列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除大学列")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(universityService.deleteUniversityByIds(ids));
    }
}
